admin panel show contact messages

jamesperet 9 years ago
parent
commit
28b8d99352

+ 4 - 0
app/controllers/admin_panel_controller.rb

@@ -24,6 +24,10 @@ class AdminPanelController < ApplicationController
24 24
   def contact_messages
25 25
     @contact_messages = ContactMessage.order('created_at DESC').all
26 26
   end
27
+  
28
+  def show_contact_message
29
+    @msg = ContactMessage.find(params[:id])
30
+  end
27 31
 
28 32
   def users
29 33
     @users = User.order('created_at DESC').all

+ 1 - 1
app/views/admin_panel/contact_messages.html.erb

@@ -10,7 +10,7 @@
10 10
 		  <div class="media-body pull-left">
11 11
 		    <h4 class="media-heading" style="margin-bottom: 0px;">
12 12
 			    <%= ('<span class="badge badge-warning" style="margin-top: -11px">' + (t "admin_panel.new") + '</span>').html_safe if msg.unread %>
13
-			    <%= link_to msg.title, contact_message_path(msg) %> 
13
+			    <%= link_to msg.title, show_contact_message_path(msg) %> 
14 14
 		    
15 15
 		    <span style="margin-top: -5px;"><small><%= t "contact.by" %> 
16 16
 			     <% if msg.user != nil %>

+ 37 - 0
app/views/admin_panel/show_contact_message.html.erb

@@ -0,0 +1,37 @@
1
+<div class="row">
2
+	<%= render 'admin_panel/sidebar_nav' %>
3
+	<div class="span9">
4
+		<div class="page-header">
5
+		  <h1>
6
+			 	 <%= @msg.title %>
7
+				 
8
+				 <div class="btn-group pull-right" >
9
+				 	<%= link_to (t 'nav.back'), admin_contact_messages_path, class: 'btn' %>
10
+			 	 </div>
11
+				 
12
+	   			 <div class="btn-group pull-right" style="margin-right: 10px;">
13
+	   				<% if @msg.unread %>
14
+	   		      		<%= link_to '<i class="icon-eye-open"></i>'.html_safe, mark_contact_message_as_readed_path(@msg), :class => 'btn' %>
15
+	   				<% else %>
16
+	   					<%= link_to '<i class="icon-eye-close"></i>'.html_safe, mark_contact_message_as_unread_path(@msg), :class => 'btn' %>
17
+	   				<% end %>
18
+	   		      	<%= link_to '<i class="icon-remove"></i>'.html_safe, @msg, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-danger' %>
19
+	   			 </div>
20
+				 
21
+		  </h1>
22
+		</div>
23
+		<%= bootstrap_flash %>
24
+ 	      <span style="margin-top: -15px;"><small><%= t "contact.by" %> 
25
+ 		     <% if @msg.user != nil %>
26
+ 		    		<%= @msg.user.full_name %>,
27
+ 			<% else %>
28
+ 				<%= @msg.email %>,
29
+ 			<% end %>
30
+ 			<%= time_ago_in_words(@msg.created_at) %> <%= t "blog.ago" %>
31
+ 	      </small></span>
32
+	    
33
+	    
34
+	    <p style="margin-top: 15px;"><%= @msg.content %></p>
35
+		
36
+	</div>
37
+</div>

+ 0 - 30
app/views/contact_messages/show.html.erb

@@ -1,30 +0,0 @@
1
-<p id="notice"><%= notice %></p>
2
-
3
-<p>
4
-  <strong>Title:</strong>
5
-  <%= @contact_message.title %>
6
-</p>
7
-
8
-<p>
9
-  <strong>Email:</strong>
10
-  <%= @contact_message.email %>
11
-</p>
12
-
13
-<p>
14
-  <strong>Content:</strong>
15
-  <%= @contact_message.content %>
16
-</p>
17
-
18
-<p>
19
-  <strong>Unread:</strong>
20
-  <%= @contact_message.unread %>
21
-</p>
22
-
23
-<% if @contact_message.user != nil %>
24
-	<p>
25
-	  <strong>User:</strong>
26
-	  <%= @contact_message.user.full_name  %>
27
-	</p>
28
-<% end %>
29
-
30
-<%= link_to 'Back', admin_contact_messages_path %>

+ 0 - 1
app/views/contact_messages/show.json.jbuilder

@@ -1 +0,0 @@
1
-json.extract! @contact_message, :id, :title, :email, :content, :unread, :user_id, :created_at, :updated_at

+ 4 - 2
config/routes.rb

@@ -1,5 +1,6 @@
1 1
 RailsWebsiteTemplate::Application.routes.draw do
2 2
   
3
+  
3 4
   resources :contact_messages, path: '/contact', :as => :contact_messages
4 5
 
5 6
   resources :uploads
@@ -10,8 +11,9 @@ RailsWebsiteTemplate::Application.routes.draw do
10 11
   get "admin" => "admin_panel#index"
11 12
   get "admin/posts" => "admin_panel#posts", :as => :admin_posts
12 13
   get "admin/contact_messages" => "admin_panel#contact_messages", :as => :admin_contact_messages
13
-  get "contact_message/:id/mark_contact_message_as_readed" => "contact_messages#readed", :as => :mark_contact_message_as_readed
14
-  get "contact_message/:id/mark_contact_message_as_unread" => "contact_messages#unread", :as => :mark_contact_message_as_unread
14
+  get "admin/contact_message/:id" => "admin_panel#show_contact_message", :as => :show_contact_message
15
+  get "admin/contact_message/:id/mark_contact_message_as_readed" => "contact_messages#readed", :as => :mark_contact_message_as_readed
16
+  get "admin/contact_message/:id/mark_contact_message_as_unread" => "contact_messages#unread", :as => :mark_contact_message_as_unread  
15 17
   get "admin/users" => "admin_panel#users", :as => :admin_users
16 18
   get "admin/users/:id/make_admin" => "admin_panel#make_admin", :as => :make_admin
17 19
   get "admin/config" => "admin_panel#site_config", :as => :admin_config